package com.wzdigit.wms.basic.enums;



import java.util.*;

/**
 * 事务类型
 */
public enum BooleanEnum implements BaseEnum {

    FALSE(0, "否", "否"),
    TRUE(1, "是", "是");

    /**
     * 枚举值
     */
    private int code;

    /**
     * 枚举名称
     */
    private String enumName;

    /**
     * 枚举实体类属性描述
     */
    private String description;

    BooleanEnum(String enumName, String description) {
        this.enumName = enumName;
        this.description = description;
    }

    BooleanEnum(int code, String enumName, String description) {
        this.code = code;
        this.enumName = enumName;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static LocationEnum getEnumByCode(int enumCode) {
        LocationEnum[] values = LocationEnum.values();
        LocationEnum samplingEnum = null;

        for (LocationEnum value : values) {
            if (value.getCode() == enumCode) {
                samplingEnum = value;
            }
        }
        return samplingEnum;
    }

    public static LocationEnum getEnumByName(String enumName) {
        LocationEnum[] values = LocationEnum.values();
        LocationEnum repairEnum = null;

        for (LocationEnum value : values) {
            if (value.getEnumName() == enumName) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }

    public static Integer getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        LocationEnum[] values = LocationEnum.values();
        for (LocationEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }

    public static Map<Integer, String> getEnumByDescription(String enumDescription) {
        Map<Integer, String> enumMap = new HashMap<Integer, String>();
        LocationEnum[] values = LocationEnum.values();
        for (LocationEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                enumMap.put(value.getCode(), value.getEnumName());
            }
        }
        return enumMap;
    }

    public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        LocationEnum[] values = LocationEnum.values();
        for (LocationEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }
}
